<!DOCTYPE html>
<html>
<meta charset="utf-8">
<meta content="IE=9" http-equiv="x-ua-compatible">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
	<div class="row">
		<div class="col-sm-12">
			<div class="ibox-content">
				<form class="form-horizontal m-t" id="signupForm">
					<input id="id" name="id" th:value="${userId}"
						   type="hidden">

					<!--<div class="form-group" readOnly="true">
						<label class="col-sm-3 control-label">直推人等级:</label>
						<div class="col-sm-8">
							<label class="radio-inline"> <input
									th:field="*{fatherUser.level}" type="radio" name="disabled" value="0" />
								分销商
							</label>
							<label class="radio-inline"> <input
								th:field="*{fatherUser.level}" type="radio" name="disabled" value="1" />
								核心
							</label>
							<label class="radio-inline"> <input
									th:field="*{fatherUser.level}" type="radio" name="disabled" value="2" />
								联创
							</label>
						</div>
					</div>-->

					<!--<div class="form-group">
						<label class="col-sm-3 control-label">直推人：</label>
						<div class="col-sm-8">
							<select data-placeholder="&#45;&#45;选择直推人&#45;&#45;" name="introUser" id="introUser"
									class="form-control chosen-select" tabindex="2" >
								<option value="-1">&#45;&#45;选择直推人&#45;&#45;</option>
								 <option th:each="user : ${userList}" th:value="${user.id}" th:text="${user.name}" th:if="${fatherUser.introUser ==user.id}" th:selected="selected"></option>
							</select>
						</div>
					</div>-->
					<div class="form-group">
						<label class="col-sm-3 control-label">直推人：</label>
						<div class="col-sm-8">
							<input id="introUser" name="introUser" class="hidden" th:value="${fatherUser.introUser}">
							<input id="name"
								   class="form-control" type="text" style="cursor: pointer;"
								   onclick="openDept($('#id').val())" readonly="readonly" placeholder="直推人" th:value="${fatherUser.name}">
						</div>
					</div>
					<!--<div class="form-group">
						<label class="col-sm-3 control-label">直推人姓名：</label>
						<div class="col-sm-8">
							<input id="name" name="name" th:value="${fatherUser.name}" class="form-control" type="text" readOnly="true">
						</div>
					</div>-->
					<div class="form-group">
							<label class="col-sm-3 control-label">用户等级：</label>
							<div class="col-sm-8">
								<label class="radio-inline">
									<input th:field="*{fatherUser.level}" type="radio"  value="0" />
									普通用户
								</label>
								<label class="radio-inline">
									<input th:field="*{fatherUser.level}" type="radio"  value="1" />
									团长
								</label>
								<label class="radio-inline">
									<input th:field="*{fatherUser.level}" type="radio" value="2" />
									核心
								</label>
								<label class="radio-inline">
									<input th:field="*{fatherUser.level}" type="radio"  value="3" />
									合伙人
								</label>
								<!--<label class="radio-inline">
									<input th:field="*{fatherUser.level}" type="radio" name="level" value="2" />
									总代
								</label>-->
								<!-- <label class="radio-inline">
									<input th:field="*{fatherUser.level}" type="radio" name="level" value="5" />
									高级分销
								</label> -->
							</div>
						</div>
					<div class="form-group">
						<label class="col-sm-3 control-label">直推人手机号：</label>
						<div class="col-sm-8">
							<input id="phone"  class="form-control" type="number"
								   th:value="${fatherUser.phone}" readOnly="true">
						</div>
					</div>
					<!-- <div class="form-group">
						<label class="col-sm-3 control-label">微信号：</label>
						<div class="col-sm-8">
							<input id="wechat" name="wechat" class="form-control" type="text"
								   th:value="${fatherUser.wechat}" readOnly="true">
						</div>
					</div> -->
					<div class="form-group">
						<label for="avator" class="col-sm-3 control-label">头像：</label>

						<div class="col-sm-8">
							<div id="file_upload">
							</div>
							<div id="img" style="padding: 5px;">
								<img th:src="${fatherUser.avator}" style='height: 60px;width: 60px'>
								<!--<i class="fa fa-close" onclick="$('#avator').val('');$('#img').html('');"></i>-->
							</div>
							<input type="hidden" id="avator"  th:value="${fatherUser.avator}" >
						</div>
					</div>

					<div class="form-group">
						<div class="col-sm-8 col-sm-offset-3">
							<button type="submit" class="btn btn-primary">提交</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<div th:include="include::footer"></div>
<script src="/js/layui.js"></script>
<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>

<!-- 自定义js -->
<script src="/js/content.js?v=1.0.0"></script>

<!-- jQuery Validation plugin javascript-->
<script src="/js/plugins/validate/jquery.validate.min.js"></script>
<script src="/js/plugins/validate/messages_zh.min.js"></script>


<!-- script src="/js/demo/form-validate-demo.js"></script> -->


<script type="text/javascript">
	$(document).ready(function() {
		validateRule();
		//setCheckedRoles();
	});
	$.validator.setDefaults({
		submitHandler : function() {
			update();
		}
	});
	function update() {
		$.ajax({
			cache : true,
			type : "POST",
			url : "/wx/memberUser/update",
			data : $('#signupForm').serialize(),// 你的formid
			async : false,
			error : function(request) {
				parent.layer.msg("系统错误，联系管理员");
			},
			success : function(data) {
				if (data.code == 0) {
					parent.layer.msg(data.msg);
					parent.reLoad();
					var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
					parent.layer.close(index);

				} else {
					parent.layer.msg(data.msg);
				}

			}
		});

	}

	function validateRule() {
		var icon = "<i class='fa fa-times-circle'></i> ";
		$("#signupForm").validate({
			rules : {

				password : {
					required : true,
					minlength : 6
				}
			},
			messages : {
				password : {
					required : icon + "请输入您的密码",
					minlength : icon + "密码必须6个字符以上"
				}
			}
		})
	}
	function openDept(id){
		layer.open({
			type:2,
			title:"选择直推人",
			maxmin : true,
			shadeClose : false, // 点击遮罩关闭层
			area : [ '300px', '450px' ],
			content:"/wx/memberUser/treeView/"+id
		})
	}
	function loadDept( deptId,deptName){
		$("#introUser").val(deptId);
		$("#name").val(deptName);
	}
</script>


</body>
</html>
